<template>
  <el-carousel indicator-position="none" height="900px">
    <el-carousel-item v-for="item in bookList" :key="item">
      <el-image :src="item.src" :fit="fill"></el-image>
    </el-carousel-item>
  </el-carousel>
  <h1 class="title" >热门书籍</h1>
  <div class="hot">
    <el-card class="hot-card" v-for="item in hotList.data">
      <template #header>
        <span class="card-head">{{ item.name }}</span>
      </template>
      <div class="card-body" style="text-align: left;">
        书号:{{ item.ISBN }}<br/>
        题材:{{ item.category }}<br/>
        作者:{{ item.editor }}<br/>
        出版社:{{ item.press }}<br/>
        
      </div>
    </el-card>
  </div>
</template>

<script setup>
import {onBeforeMount, reactive} from 'vue'
import {} from 'element-plus'
import {get} from '../../stores/requestMethod'

const bookList = [
  {
    name : 'book1',
    src : 'https://img.gejiba.com/images/e7ac552ff7326f4994082067218e28b4.jpg',
    title : 'book1'
  },
  {
    name : 'book2',
    src : 'https://img.gejiba.com/images/56296a72ec00414c89fb8166e23e57f8.jpg',
    title : 'book2'
  },
  {
    name : 'book3',
    src : 'https://img.gejiba.com/images/7eb9ee48d4d4d29eec2c0b920b802604.jpg',
    title : 'book3'
  }
]

const hotList = reactive(
    {
    data :[]
    }
)
const getHot = () =>{
    get('http://127.0.0.1:5000/books/hot',
        (res) => {
            console.log(res);
            hotList.data = res.data
        }
    )
}
onBeforeMount(() => {
    getHot()
})
</script>

<style scoped>
.title{
  margin: 20px 0;
  font-weight: lighter;
  font-size: 60px;
  letter-spacing: 5px;
}
.hot{
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}
.hot-card{
  width: 260px;
  height: 230px;
  margin-right: 20px;
  margin-bottom: 10px;
}
.card-head{
  margin: 20px 0;
  font-weight: lighter;
  font-size: 20px;
  color: #606266;
  letter-spacing: 5px;
}
.card-body{
  line-height: 30px;
}
.el-carousel__item h3 {
  display: flex;
  color: #475669;
  opacity: 0.75;
  line-height: 300px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
